package com.yueya.common.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.yueya.common.model.Resp;
import com.yueya.common.util.RelativeDateFormat;

import net.sf.json.JSONObject;

public class BaseService {

	protected int pageNumber = 1;
	protected int pageSize = 10;
	protected Resp resp = new Resp();

	public static String format(String time) throws ParseException {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:m:s");
		Date date = format.parse(time);
		String formatTime = RelativeDateFormat.format(date);
		return formatTime;
	}

	/**
	 * 判断KEY是否在JSON存在,如果有一个不存在,则为false
	 * 
	 * @param keys
	 * @return
	 */
	public static boolean containsKey(JSONObject jo, String... keys) {
		boolean bl = true;
		for (String k : keys) {
			if (!jo.containsKey(k)) {
				bl = false;
				break;
			}
		}
		return bl;
	}

}
